import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ModelPage, ModelId, ModelAdd, DataResult } from "./types";

// 获取充值模板库列表
export function productTmplLibrary<T>(
  data: ModelPage
): AxiosPromise<DataResult<T>> {
  return request({
    url: "/api/Templates/search",
    method: "get",
    params: data,
  });
}

// 新增 - 充值模板库
export function creatTemplates<T>(data: ModelAdd): AxiosPromise<DataResult<T>> {
  return request({
    url: "/api/Templates",
    method: "post",
    data,
  });
}

// 更新 - 充值模板库
export function updateTmplLibrary<T>(
  data: ModelAdd
): AxiosPromise<DataResult<T>> {
  return request({
    url: `/api/Templates/${data.id}`,
    method: "put",
    data,
  });
}

// 删除 - 充值模板库
export function removeTmplLibrary<T>(
  data: ModelId
): AxiosPromise<DataResult<T>> {
  return request({
    url: `/api/Templates/${data}`,
    method: "delete",
  });
}
